package com.mxpio.erp.technology.service.impl;

import com.mxpio.erp.common.enums.OrderStatusEnums;
import com.mxpio.erp.common.technology.entity.BomInfo;
import com.mxpio.erp.common.technology.service.BomInfoService;
import com.mxpioframework.common.vo.Result;
import com.mxpioframework.system.service.impl.BaseServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class BomInfoServiceImpl extends BaseServiceImpl<BomInfo> implements BomInfoService {
    @Transactional(
            readOnly = false
    )
    @Override
    public Result<BomInfo> updateBpmnStatus(BomInfo bomInfo, OrderStatusEnums.BpmnStatus bpmnStatus){
        bomInfo.setBpmnStatus(bpmnStatus.getStatusCode());
        this.update(bomInfo);
        return Result.OK();
    }

    @Override
    public String increaseVersion(String version){
        String ver = StringUtils.substring(version,1,StringUtils.indexOf(version,"."));
        return "V"+(Integer.parseInt(ver)+1)+".0";
    }

}
